#include<bits/stdc++.h>
using namespace std;

class Solution
{
private:
    /* data */
public:
    bool canJump(vector<int>& nums){
        if(nums.size()==1){
            return true;
        }
        vector<int> vec(nums.size()+1,0);
        vec[0]=nums[0];
        for(int i=1;i<nums.size();++i){
            if(vec[i-1]>=i){
                vec[i]=max(i+nums[i],vec[i-1]);
                // cout<<vec[i]<<endl;
            }
        }
        return vec[nums.size()-1];
    }
};



int main(int argc, char const *argv[])
{
    /* code */
    // vector<int> nums={2,3,1,1,4};
    vector<int> nums={3,2,1,0,4};
    Solution s;
    bool res = s.canJump(nums);
    cout<<res<<endl;
    return 0;
}
